@extends('admin.main')
@section('content')
    <div class="admin-content">
        <div class="am-cf am-padding am-padding-bottom-0">
            <div class="am-fl am-cf">
                <strong class="am-text-primary am-text-lg">后台设置</strong> /
                <small>用户注册</small>
            </div>
        </div>
        <hr>
        <div class="am-g">
            @include('admin.layouts.adminInfo')
            <div class="am-u-sm-12 am-u-md-8 am-u-md-pull-4">
                <form action="{{$prefix_url}}{{isset($data)?'/'.$data->id:''}}"
                      class="am-form" method="POST" enctype="multipart/form-data">
                    {{csrf_field()}}
                    <input type='hidden' name='_method' value='POST'/>
                    <div class='am-form-group'>
                        <label>手机号码：</label>
                        <input type="text" name="phone" placeholder="手机号码" pattern='^1[34578]\d{9}$' required value="{{isset($data)?$data->phone:''}}">
                    </div>
                    <div class='am-form-group'>
                        <label>用户名：</label>
                        <input type="text" name="name" placeholder="用户名" minlength='1' maxlength='20' required value="{{isset($data)?$data->name:''}}">
                    </div>
                    <div class='am-form-group'>
                        <label>用户类型：</label>
                        <select name="type" required>
                            @foreach($types as $key => $type)
                            <option value="{{$key}}" {{(isset($data)&&$data->type==$key)?'selected':''}}>{{$type}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class='am-form-group'>
                        <label>用户性别：</label>
                        <select name="sex" required>
                            <option value="1" {{(isset($data)&&$data->sex==1)?'selected':''}}>男</option>
                            <option value="2" {{(isset($data)&&$data->sex==2)?'selected':''}}>女</option>
                        </select>
                    </div>
                    <div class='am-form-group'>
                        <label>用户头像：</label>
                        @if(isset($data) && $data->head
                            && file_exists(ltrim($data->head,'/')))
                            (上传图片将覆盖当前头像)
                        @endif
                        <input type="file" name="head"
                               style="padding:5px;width:100%;border:1px solid #cccccc;background:#f0f0f0;">
                        @if(isset($data) && $data->head
                            && file_exists(ltrim($data->head,'/')))
                            <p>当前头像：</p>
                            <img src="{{$data->head}}" width="500">
                        @endif
                    </div>
                    <div class='am-form-group'>
                        <label>介绍人：</label>
                        <input type="text" name="introducer" placeholder="介绍人" value="{{isset($data)?$data->introducer:''}}">
                    </div>
                    <button type='button' class='am-btn am-btn-primary'
                            onclick='history.go(-1);'>返回</button>
                    <button type='submit' class='am-btn am-btn-primary'>
                        保存更新</button>
                </form>
            </div>
        </div>
    </div>
@stop